_f_a_i_l Specifies the action to take when the stencil test fails. Six
symbolic constants are accepted: GGGGLLLL____KKKKEEEEEEEEPPPP, GGGGLLLL____ZZZZEEEERRRROOOO, GGGGLLLL____RRRREEEEPPPPLLLLAAAACCCCEEEE,
GGGGLLLL____IIIINNNNCCCCRRRR, GGGGLLLL____DDDDEEEECCCCRRRR, and GGGGLLLL____IIIINNNNVVVVEEEERRRRTTTT. The initial value is GGGGLLLL____KKKKEEEEEEEEPPPP.
_z_f_a_i_l Specifies the stencil action when the stencil test passes, but the
depth test fails. _z_f_a_i_l accepts the same symbolic constants as
_f_a_i_l. The initial value is GGGGLLLL____KKKKEEEEEEEEPPPP.
_z_p_a_s_s Specifies the stencil action when both the stencil test and the
depth test pass, or when the stencil test passes and either there
is no depth buffer or depth testing is not enabled. _z_p_a_s_s accepts
the same symbolic constants as _f_a_i_l. The initial value is GGGGLLLL____KKKKEEEEEEEEPPPP.
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
Stenciling, like depth-buffering, enables and disables drawing on a per-
pixel basis. You draw into the stencil planes using GL drawing
primitives, then render geometry and images, using the stencil planes to
mask out portions of the screen. Stenciling is typically used in
multipass rendering algorithms to achieve special effects, such as
decals, outlining, and constructive solid geometry rendering.
The stencil test conditionally eliminates a pixel based on the outcome of
a comparison between the value in the stencil buffer and a reference
value. To enable and disable the test, call ggggllllEEEEnnnnaaaabbbblllleeee and ggggllllDDDDiiiissssaaaabbbblllleeee with
argument GGGGLLLL____SSSSTTTTEEEENNNNCCCCIIIILLLL____TTTTEEEESSSSTTTT; to control it, call ggggllllSSSStttteeeennnncccciiiillllFFFFuuuunnnncccc.
ggggllllSSSStttteeeennnncccciiiillllOOOOpppp takes three arguments that indicate what happens to the
stored stencil value while stenciling is enabled. If the stencil test
fails, no change is made to the pixel's color or depth buffers, and _f_a_i_l
specifies what happens to the stencil buffer contents. The following six
actions are possible.
GGGGLLLL____KKKKEEEEEEEEPPPP Keeps the current value.
GGGGLLLL____ZZZZEEEERRRROOOO Sets the stencil buffer value to 0.
GGGGLLLL____RRRREEEEPPPPLLLLAAAACCCCEEEE Sets the stencil buffer value to _r_e_f, as specified by
GGGGLLLL____IIIINNNNCCCCRRRR Increments the current stencil buffer value. Clamps to
the maximum representable unsigned value.
GGGGLLLL____DDDDEEEECCCCRRRR Decrements the current stencil buffer value. Clamps to
0.
GGGGLLLL____IIIINNNNVVVVEEEERRRRTTTT Bitwise inverts the current stencil buffer value.
Stencil buffer values are treated as unsigned integers. When incremented
n
and decremented, values are clamped to 0 and 2 -1, where n is the value
returned by querying GGGGLLLL____SSSSTTTTEEEENNNNCCCCIIIILLLL____BBBBIIIITTTTSSSS.
The other two arguments to ggggllllSSSStttteeeennnncccciiiillllOOOOpppp specify stencil buffer actions
that depend on whether subsequent depth buffer tests succeed (_z_p_a_s_s) or
fail (_z_f_a_i_l) (see
ggggllllDDDDeeeepppptttthhhhFFFFuuuunnnncccc). The actions are specified using the same six symbolic
constants as _f_a_i_l. Note that _z_f_a_i_l is ignored when there is no depth
buffer, or when the depth buffer is not enabled. In these cases, _f_a_i_l
and _z_p_a_s_s specify stencil action when the stencil test fails and passes,
respectively.
NNNNOOOOTTTTEEEESSSS
Initially the stencil test is disabled. If there is no stencil buffer,
no stencil modification can occur and it is as if the stencil tests
always pass, regardless of any call to ggggllllSSSStttteeeennnncccciiiillllOOOOpppp.
EEEERRRRRRRROOOORRRRSSSS
GGGGLLLL____IIIINNNNVVVVAAAALLLLIIIIDDDD____EEEENNNNUUUUMMMM is generated if _f_a_i_l, _z_f_a_i_l, or _z_p_a_s_s is any value other
than the six defined constant values.
GGGGLLLL____IIIINNNNVVVVAAAALLLLIIIIDDDD____OOOOPPPPEEEERRRRAAAATTTTIIIIOOOONNNN is generated if ggggllllSSSStttteeeennnncccciiiillllOOOOpppp is executed between the
execution of ggggllllBBBBeeeeggggiiiinnnn and the corresponding execution of ggggllllEEEEnnnndddd.